Class ADOConnection

Description

Connection object. For connecting to databases, and executing queries.

Located in /adodb/adodb.inc.php (line 126)


	
			
Direct descendents
Class Description
Connection object. For connecting to databases, and executing queries.
Connection object. For connecting to databases, and executing queries.
ADODB_csv Connection object. For connecting to databases, and executing queries.
ADODB_odbc Connection object. For connecting to databases, and executing queries.
Variable Summary
Method Summary
ADOConnection ADOConnection ()
the ActualType (mixed $meta)
true BeginTrans ()
void BlankRecordSet ([mixed $id = false])
RecordSet &CacheExecute ([secs2cache] $secs2cache, [sql $sql = false], [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
void CacheFlush (mixed $sql)
the &CachePageExecute (secs2cache $secs2cache, sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
the &CacheSelectLimit ([secs2cache] $secs2cache, sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
void CharMax ()
void Close ()
void CommitLock (mixed $table)
true/false. CommitTrans ()
concatenated Concat (s 0)
true Connect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
date DBDate (d $d)
timestamp DBTimeStamp (ts $ts)
void Disconnect ()
the ErrorMsg ()
void ErrorNative ()
the ErrorNo ()
RecordSet &Execute (sql $sql, [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
GenID ([mixed $seqname = 'adodbseq'], [mixed $startID = 1])
void &GetAll (sql $sql, [[inputarr] $inputarr = false])
void GetInsertSQL (mixed &$rs, mixed $arrFields, [mixed $magicq = false])
void GetOne (sql $sql, [[inputarr] $inputarr = false])
void GetRow (sql $sql, [[inputarr] $inputarr = false])
void GetUpdateSQL (mixed &$rs, mixed $arrFields, [mixed $forceUpdate = false], [mixed $magicq = false])
the Insert_ID ()
void &LimitQuery (mixed $sql, mixed $offset, mixed $count)
array MetaColumnNames (mixed $table)
array MetaColumns (mixed $table)
an MetaPrimaryKeys (mixed $table)
array MetaTables ()
void nextId (mixed $seq_name)
the &PageExecute (sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[arg3] $arg3 = false], [secs2cache] $secs2cache)
return PConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
the PO_Insert_ID ([mixed $table = ""], [mixed $id = ""])
return Prepare (sql $sql)
quoted qstr (s $s, [[magic_quotes] $magic_quotes = false])
void &Query (mixed $sql, [mixed $inputarr = false])
void Quote (mixed $s)
void RollbackLock (mixed $table)
true/false. RollbackTrans ()
void RowLock ($table $table, $where $where)
true SelectDB (dbName $dbName)
the &SelectLimit (sql $sql, [[offset] $nrows = -1], [[rows] $offset = -1], [[inputarr] $inputarr = false], [[arg3] $arg3 = false], [secs2cache] $secs2cache)
void SetFetchMode (mixed $mode)
void TextMax ()
void UnixDate (mixed $d)
void UpdateBlob (mixed $table, mixed $column, mixed $val, mixed $where, [mixed $blobtype = 'BLOB'])
void UpdateBlobFile (mixed $table, mixed $column, mixed $path, mixed $where, [mixed $blobtype = 'BLOB'])
void UpdateClob (mixed $table, mixed $column, mixed $val, mixed $where)
void _gencachename (mixed $sql, mixed $createdir)
the &_rs2rs (rs &$rs, [[nrows] $nrows = -1], [[offset] $offset = -1])
Variables
mixed $autoCommit = true (line 177)
mixed $cacheSecs = 3600 (line 157)
mixed $charSet = false (line 146)
mixed $concat_operator = '+' (line 138)

Redefined in descendants as:
mixed $database = '' (line 132)
mixed $dataProvider = 'native' (line 130)

Redefined in descendants as:
mixed $debug = false (line 136)
mixed $false = '0' (line 142)
mixed $fmtDate = "'Y-m-d'" (line 139)

Redefined in descendants as:
mixed $genID = 0 (line 153)
mixed $hasAffectedRows = false (line 145)

Redefined in descendants as:
mixed $hasGenID = false (line 152)

Redefined in descendants as:
mixed $hasInsertID = false (line 144)

Redefined in descendants as:
mixed $hasLimit = false (line 149)

Redefined in descendants as:
mixed $hasMoveFirst = false (line 151)

Redefined in descendants as:
mixed $hasTop = false (line 148)

Redefined in descendants as:
mixed $host = '' (line 133)
mixed $isoDates = false (line 156)

Redefined in descendants as:
mixed $maxblobsize = 8000 (line 137)
mixed $metaTablesSQL = '' (line 147)

Redefined in descendants as:
mixed $noNullStrings = false (line 161)
mixed $password = '' (line 135)
mixed $raiseErrorFn = false (line 154)
mixed $readOnly = false (line 150)
mixed $replaceQuote = "\\'" (line 143)

Redefined in descendants as:
mixed $sysDate = false (line 158)

Redefined in descendants as:
mixed $true = '1' (line 141)
mixed $upperCase = false (line 155)

Redefined in descendants as:
mixed $user = '' (line 134)
mixed $_bindInputArray = false (line 175)

Redefined in descendants as:
mixed $_connectionID = false (line 166)
mixed $_errorMsg = '' (line 168)
mixed $_isPersistentConnection = false (line 173)
mixed $_queryID = false (line 171)
Methods
Constructor ADOConnection (line 182)

Constructor

ADOConnection ADOConnection ()
ActualType (line 935)
  • return: actual type of the data or false if no such type available
the ActualType (mixed $meta)

Redefined in descendants as:
Affected_Rows (line 525)
  • return: rows affected by UPDATE/DELETE
# Affected_Rows ()
BeginTrans (line 993)

Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans().

  • return: if succeeded or false if database does not support transactions
true BeginTrans ()

Redefined in descendants as:
BlankRecordSet (line 911)

not used - will probably remove in future

void BlankRecordSet ([mixed $id = false])
CacheExecute (line 768)

Execute SQL, caching recordsets.

  • return: or false
RecordSet &CacheExecute ([secs2cache] $secs2cache, [sql $sql = false], [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
  • [secs2cache] $secs2cache: seconds to cache data, set to 0 to force query. This is an optional parameter.
  • sql $sql: SQL statement to execute
  • [inputarr] $inputarr: holds the input data to bind to
  • [arg3] $arg3: reserved for john lim for future use
CacheFlush (line 737)
void CacheFlush (mixed $sql)
CachePageExecute (line 1224)

Will select the supplied $page number from a recordset, given that it is paginated in pages of $nrows rows per page. It also saves two boolean values saying if the given page is the first and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.

  • return: recordset ($rs->databaseType == 'array')
the &CachePageExecute (secs2cache $secs2cache, sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
  • secs2cache $secs2cache: seconds to cache data, set to 0 to force query
  • sql $sql
  • nrows $nrows: is the number of rows per page to get
  • page $page: is the page number to get (1-based)
  • [inputarr] $inputarr: array of bind variables
  • [arg3] $arg3: is a private parameter only used by jlim
CacheSelectLimit (line 724)

Will select, getting rows from $offset (1-based), for $nrows.

This simulates the MySQL "select * from table limit $offset,$nrows" , and the PostgreSQL "select * from table limit $nrows offset $offset". Note that MySQL and PostgreSQL parameter ordering is the opposite of the other. eg. CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based)

BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set

  • return: recordset ($rs->databaseType == 'array')
the &CacheSelectLimit ([secs2cache] $secs2cache, sql $sql, [[offset] $nrows = -1], [[nrows] $offset = -1], [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
  • [secs2cache] $secs2cache: seconds to cache data, set to 0 to force query. This is optional
  • sql $sql
  • [offset] $nrows: is the row to start calculations from (1-based)
  • [nrows] $offset: is the number of rows to get
  • [inputarr] $inputarr: array of bind variables
  • [arg3] $arg3: is a private parameter only used by jlim
CharMax (line 959)
void CharMax ()

Redefined in descendants as:
Close (line 977)

Close Connection

void Close ()
CommitLock (line 314)
void CommitLock (mixed $table)
CommitTrans (line 1001)

If database does not support transactions, always return true as data always commited

true/false. CommitTrans ()

Redefined in descendants as:
Concat (line 1106)

Different SQL databases used different methods to combine strings together.

This function provides a wrapper.

  • return: string
concatenated Concat (s 0)
  • s 0:

    variable number of string parameters

    Usage: $db->Concat($str1,$str2);


Redefined in descendants as:
Connect (line 198)

Connect to database

  • return: or false
true Connect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
  • [argHostname] $argHostname: Host to connect to
  • [argUsername] $argUsername: Userid to login
  • [argPassword] $argPassword: Associated password
  • [argDatabaseName] $argDatabaseName: database
DBDate (line 1120)

Converts a date "d" to a string that the database can understand.

  • return: string in database date format
date DBDate (d $d)
  • d $d: a date in Unix date time format.
DBTimeStamp (line 1141)

Converts a timestamp "ts" to a string that the database can understand.

  • return: string in database timestamp format
timestamp DBTimeStamp (ts $ts)
  • ts $ts: a timestamp in Unix date time format.
Disconnect (line 362)

PEAR DB Compat - do not use internally

void Disconnect ()
ErrorMsg (line 540)
  • return: last error message
the ErrorMsg ()

Redefined in descendants as:
ErrorNative (line 288)

PEAR DB Compat - do not use internally.

void ErrorNative ()
ErrorNo (line 549)
  • return: last error number. Normally 0 means no error.
the ErrorNo ()

Redefined in descendants as:
Execute (line 376)

Execute SQL

  • return: or false
RecordSet &Execute (sql $sql, [[inputarr] $inputarr = false], [[arg3] $arg3 = false])
  • sql $sql: SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text)
  • [inputarr] $inputarr: holds the input data to bind to. Null elements will be set to null.
  • [arg3] $arg3: reserved for john lim for future use

Redefined in descendants as:
GenID (line 473)

Generates a sequence id and stores it in $this->genID; GenID is only available if $this->hasGenID = true;

  • return: if not supported, otherwise a sequence id
0 GenID ([mixed $seqname = 'adodbseq'], [mixed $startID = 1])

Redefined in descendants as:
GetAll (line 675)

Return all rows. Compat with PEAR DB

void &GetAll (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array
GetInsertSQL (line 848)

Generates an Insert Query based on an existing recordset.

$arrFields is an associative array of fields with the value that should be assigned.

Note: This function should only be used on a recordset that is run against a single table.

void GetInsertSQL (mixed &$rs, mixed $arrFields, [mixed $magicq = false])
GetOne (line 656)

Return first element of first row of sql statement. Recordset is disposed for you.

void GetOne (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array
GetRow (line 691)

Return one row of sql statement. Recordset is disposed for you.

void GetRow (sql $sql, [[inputarr] $inputarr = false])
  • sql $sql: SQL statement
  • [inputarr] $inputarr: input bind array
GetUpdateSQL (line 833)

Generates an Update Query based on an existing recordset.

$arrFields is an associative array of fields with the value that should be assigned.

Note: This function should only be used on a recordset that is run against a single table.

"Jonathan Younger" <jyounger@unilab.com>

void GetUpdateSQL (mixed &$rs, mixed $arrFields, [mixed $forceUpdate = false], [mixed $magicq = false])
Insert_ID (line 498)
  • return: last inserted ID. Not all databases support this.
the Insert_ID ()
LimitQuery (line 351)

PEAR DB Compat - do not use internally

void &LimitQuery (mixed $sql, mixed $offset, mixed $count)
MetaColumnNames (line 1084)

List columns names in a table as an array.

  • return: of column names for current table.
array MetaColumnNames (mixed $table)
MetaColumns (line 1051)

List columns in a database as an array of ADOFieldObjects.

See top of file for definition of object.

  • return: of ADOFieldObjects for current table.
array MetaColumns (mixed $table)

Redefined in descendants as:
MetaDatabases (line 1020)

return the databases that the driver can connect to.

Some databases will return an empty array.

  • return: array of database names.
an MetaDatabases ()

Redefined in descendants as:
MetaPrimaryKeys (line 558)
  • return: array with the primary key columns in it.
an MetaPrimaryKeys (mixed $table)
MetaTables (line 1026)
  • return: of tables for current database.
array MetaTables ()

Redefined in descendants as:
nextId (line 297)

PEAR DB Compat - do not use internally.

void nextId (mixed $seq_name)
PageExecute (line 1203)

Will select the supplied $page number from a recordset, given that it is paginated in pages of $nrows rows per page. It also saves two boolean values saying if the given page is the first and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.

See readme.htm#ex8 for an example of usage.

  • return:

    recordset ($rs->databaseType == 'array')

    NOTE: phpLens uses a different algorithm and does not use PageExecute().

the &PageExecute (sql $sql, nrows $nrows, page $page, [[inputarr] $inputarr = false], [[arg3] $arg3 = false], [secs2cache] $secs2cache)
  • sql $sql
  • nrows $nrows: is the number of rows per page to get
  • page $page: is the page number to get (1-based)
  • [inputarr] $inputarr: array of bind variables
  • [arg3] $arg3: is a private parameter only used by jlim
  • [secs2cache] $secs2cache: is a private parameter only used by jlim
PConnect (line 229)

Establish persistent connect to database

  • return: true or false
return PConnect ([[argHostname] $argHostname = ""], [[argUsername] $argUsername = ""], [[argPassword] $argPassword = ""], [[argDatabaseName] $argDatabaseName = ""])
  • [argHostname] $argHostname: Host to connect to
  • [argUsername] $argUsername: Userid to login
  • [argPassword] $argPassword: Associated password
  • [argDatabaseName] $argDatabaseName: database
PO_Insert_ID (line 512)

Portable Insert ID. Pablo Roca <pabloroca@mvps.org>

  • return: last inserted ID. All databases support this. But aware possible problems in multiuser environments. Heavy test this before deploying.
the PO_Insert_ID ([mixed $table = ""], [mixed $id = ""])
Prepare (line 270)

Should prepare the sql statement and return the stmt resource.

For databases that do not support this, we return the $sql. To ensure compatibility with databases that do not support prepare:

$stmt = $db->Prepare("insert into table (id, name) values (?,?)"); $db->Execute($stmt,array(1,'Jill')) or die('insert failed'); $db->Execute($stmt,array(2,'Joe')) or die('insert failed');

  • return: TRUE or FALSE, or the $sql.
return Prepare (sql $sql)
  • sql $sql: SQL to send to database

Redefined in descendants as:
qstr (line 1162)

Converts a timestamp "ts" to a string that the database can understand.

An example is $db->qstr("Don't bother",magic_quotes_runtime());

  • return: string to be sent back to database
quoted qstr (s $s, [[magic_quotes] $magic_quotes = false])
  • s $s: the string to quote
  • [magic_quotes] $magic_quotes: if $s is GET/POST var, set to get_magic_quotes_gpc(). This undoes the stupidity of magic quotes for GPC.
Query (line 340)

PEAR DB Compat - do not use internally.

void &Query (mixed $sql, [mixed $inputarr = false])
Quote (line 279)

PEAR DB Compat - do not use internally.

void Quote (mixed $s)
RollbackLock (line 319)
void RollbackLock (mixed $table)
RollbackTrans (line 1010)

If database does not support transactions, rollbacks always fail, so return false

true/false. RollbackTrans ()

Redefined in descendants as:
RowLock (line 309)

Lock a row, will escalate and lock the table if row locking not supported will normally free the lock at the end of the transaction

void RowLock ($table $table, $where $where)
  • $table $table: name of table to lock
  • $where $where: where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock
SelectDB (line 570)

Choose a database to connect to. Many databases do not support this.

  • return: or false
true SelectDB (dbName $dbName)
  • dbName $dbName: is the name of the database to select

Redefined in descendants as:
SelectLimit (line 594)

Will select, getting rows from $offset (1-based), for $nrows.

This simulates the MySQL "select * from table limit $offset,$nrows" , and the PostgreSQL "select * from table limit $nrows offset $offset". Note that MySQL and PostgreSQL parameter ordering is the opposite of the other. eg. SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based)

Uses SELECT TOP for Microsoft databases (when $this->hasTop is set) BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set

  • return: recordset ($rs->databaseType == 'array')
the &SelectLimit (sql $sql, [[offset] $nrows = -1], [[rows] $offset = -1], [[inputarr] $inputarr = false], [[arg3] $arg3 = false], [secs2cache] $secs2cache)
  • sql $sql
  • [offset] $nrows: is the row to start calculations from (1-based)
  • [rows] $offset: is the number of rows to get
  • [inputarr] $inputarr: array of bind variables
  • [arg3] $arg3: is a private parameter only used by jlim
  • [secs2cache] $secs2cache: is a private parameter only used by jlim

Redefined in descendants as:
SetFetchMode (line 330)

PEAR DB Compat - do not use internally.

The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical for easy porting :-)

void SetFetchMode (mixed $mode)
TextMax (line 968)
void TextMax ()

Redefined in descendants as:
UnixDate (line 251)
void UnixDate (mixed $d)
UpdateBlob (line 864)

Usage: UpdateBlob('TABLE', 'COLUMN', $var, 'ID=1', 'BLOB');

$blobtype supports 'BLOB' and 'CLOB'

$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');

void UpdateBlob (mixed $table, mixed $column, mixed $val, mixed $where, [mixed $blobtype = 'BLOB'])

Redefined in descendants as:
UpdateBlobFile (line 882)

Usage: UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1', 'BLOB');

$blobtype supports 'BLOB' and 'CLOB'

$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1');

void UpdateBlobFile (mixed $table, mixed $column, mixed $path, mixed $where, [mixed $blobtype = 'BLOB'])
UpdateClob (line 902)

Usage: UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB');

$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)'); $conn->UpdateClob('clobtable','clobcol',$clob,'id=1');

void UpdateClob (mixed $table, mixed $column, mixed $val, mixed $where)
_gencachename (line 745)
void _gencachename (mixed $sql, mixed $createdir)
_rs2rs (line 633)

Convert recordset to an array recordset input recordset's cursor should be at beginning, and old $rs will be closed.

  • return: new recordset
the &_rs2rs (rs &$rs, [[nrows] $nrows = -1], [[offset] $offset = -1])
  • rs &$rs: the recordset to copy
  • [nrows] $nrows: number of rows to retrieve (optional)
  • [offset] $offset: offset by number of rows (optional)

Documentation generated on Thu, 04 Sep 2008 16:14:45 +0400 by phpDocumentor 1.3.0RC3